Shader "Unlit/UpgradeBlitShader"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
				overlay1("overlay1",2D)="white"{}
				overlay2("overlay2",2D)="white"{}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 100

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            // make fog work
            #pragma multi_compile_fog

            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                UNITY_FOG_COORDS(1)
                float4 vertex : SV_POSITION;
            };

            sampler2D _MainTex;
            sampler2D overlay1;
            sampler2D overlay2;
            float4 _MainTex_ST;

            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = TRANSFORM_TEX(v.uv, _MainTex);
                UNITY_TRANSFER_FOG(o,o.vertex);
                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
                fixed4 result = tex2D(_MainTex, i.uv);
                fixed4 over1=tex2D(overlay1,i.uv);
								fixed4 over2=tex2D(overlay2,i.uv);
                
								fixed alpha0=result.a;
								fixed alpha1=over1.a;
								result=result*(1-alpha1)+over1*alpha1;
								fixed alpha2=over2.a;
								result=result*(1-alpha2)+over2*alpha2;
                result.a=saturate(alpha0+alpha1+alpha2);

                return result;
            }
            ENDCG
        }
    }
}
